package com.min.star.controller;

import java.util.List;

import javax.servlet.http.HttpSession;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import com.min.star.model.Systeminfo;
import com.min.star.service.ISysteminfoService;
@Controller
@RequestMapping("/system")
public class SysteminfoController {
	
	private Log log = LogFactory.getLog(SysteminfoController.class);
	@Autowired
	private ISysteminfoService systemService;
	
	@RequestMapping("/query")
	public String selectSystemList(Systeminfo system, Model model) {
		List<Systeminfo> systemList = this.systemService.selectSystemList();
		model.addAttribute("systemList", systemList.get(0));
		return "/admin/adminPersonal";
	}
	
	@RequestMapping("/edit/{data}")
	public String editSystem(@PathVariable("data") List<Object> data, Model model,HttpSession session) {
		int ret = systemService.editSystem(data.get(0), data.get(1));
		List<Systeminfo> systemList = this.systemService.selectSystemList();
		model.addAttribute("systemList", systemList.get(0));
		String  message = null;
		message = ret > 0 ? "保存成功":"保存失败";
		session.setAttribute("message", message);
		return "/admin/adminPersonal";
	}
	
}
